﻿using MC;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Station.Inspect.Forms
{
    public partial class FormPath : Form
    {
        public FormPath()
        {
            InitializeComponent();
        }
        private void FormPath_Load(object sender, EventArgs e)
        {
            UpdateData(false);
        }
        private void btnSetPos0_Click(object sender, EventArgs e)
        {
            tbPosLT.Text = StaInspect.Instance.GetCurPos().ToString();
        }

        private void btnSetPos1_Click(object sender, EventArgs e)
        {
            tbPosRT.Text = StaInspect.Instance.GetCurPos().ToString();
        }

        private void btnSetPos2_Click(object sender, EventArgs e)
        {
            tbPosLB.Text = StaInspect.Instance.GetCurPos().ToString();
        }
        void UpdateData(bool control2Value = true)
        {
            Project prj = StaInspect.Instance.Prj;
            if (control2Value)
            {
                prj.pathLT = TargetPos.Parse(tbPosLT.Text);
                prj.pathRT = TargetPos.Parse(tbPosRT.Text);
                prj.pathLB = TargetPos.Parse(tbPosLB.Text);
                prj.pathEx = int.Parse(tbD.Text);
                int w = int.Parse(tbRow.Text);
                int c = int.Parse(tbCol.Text);
                prj.pathSize = new Size(w, c);
            }
            else
            {
                tbPosLT.Text = prj.pathLT.ToString();
                tbPosRT.Text = prj.pathRT.ToString();
                tbPosLB.Text = prj.pathLB.ToString();
                tbD.Text = prj.pathEx.ToString();
                tbRow.Text = prj.pathSize.Width.ToString();
                tbCol.Text = prj.pathSize.Height.ToString();
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            UpdateData(true);
        }
    }
}
